package com.sec.android.app.myfiles.module.preview;

import android.app.Activity;

import com.sec.android.app.myfiles.fragment.AbsMyFilesFragment;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;
import com.sec.android.app.myfiles.operation.FileOperationArgs;
import com.sec.android.app.myfiles.operation.FileOperationFragment;
import com.sec.android.app.myfiles.operation.FileOperator;

import org.puremvc.java.multicore.interfaces.INotification;
import org.puremvc.java.multicore.patterns.command.SimpleCommand;

public class PreviewCompressCmd extends SimpleCommand {

    private Activity mActivity;
    private AbsMyFilesFragment mFragment;
    private FileRecord mArchiveRecord;

    @Override
    public void execute(INotification notification) {
        Object[] params = (Object[]) notification.getBody();
        final int processId = (Integer) params[0];
        mActivity = (Activity) params[1];
        mFragment = (AbsMyFilesFragment) params[2];
        mArchiveRecord = (FileRecord) params[3];
        doPreview(processId);
    }

    private void doPreview(int processId) {
        FileOperationArgs args = new FileOperationArgs();
        args.mProcessId = processId;
        args.mSrc = mArchiveRecord;
        FileOperationFragment.createInstance(mActivity, mFragment, mActivity.getFragmentManager(),
                FileOperator.Operation.PREVIEW_COMPRESS, args, null).showAllowingStateLoss(mFragment.getFragmentManager(),"file_operation_dialog");
    }
}
